home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / cellcont / data1.cab / VCDEMO_Files / DemoFileDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-11-20  |  2.1 KB  |  89 lines

  1. // DemoFileDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "VCDemo.h"
  6. #include "DemoFileDlg.h"
  7. #include "cell.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CDemoFileDlg dialog
  17.  
  18.  
  19. CDemoFileDlg::CDemoFileDlg(CWnd* pParent /*=NULL*/)
  20.     : CDialog(CDemoFileDlg::IDD, pParent)
  21. {
  22.     //{{AFX_DATA_INIT(CDemoFileDlg)
  23.     m_filename = _T("");
  24.     //}}AFX_DATA_INIT
  25.     isopen = FALSE;
  26. }
  27.  
  28.  
  29. void CDemoFileDlg::DoDataExchange(CDataExchange* pDX)
  30. {
  31.     CDialog::DoDataExchange(pDX);
  32.     //{{AFX_DATA_MAP(CDemoFileDlg)
  33.     DDX_Text(pDX, IDC_EDIT_FILENAME, m_filename);
  34.     DDX_Control(pDX, IDC_SGCTRL1, m_ctrl);
  35.     //}}AFX_DATA_MAP
  36. }
  37.  
  38.  
  39. BEGIN_MESSAGE_MAP(CDemoFileDlg, CDialog)
  40.     //{{AFX_MSG_MAP(CDemoFileDlg)
  41.     ON_BN_CLICKED(IDC_BUTTON_BROWSER, OnButtonBrowser)
  42.     ON_BN_CLICKED(IDC_BUTTON_OPEN, OnButtonOpen)
  43.     ON_BN_CLICKED(IDC_BUTTON_SAVE, OnButtonSave)
  44.     //}}AFX_MSG_MAP
  45. END_MESSAGE_MAP()
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CDemoFileDlg message handlers
  49.  
  50. void CDemoFileDlg::OnButtonBrowser() 
  51. {
  52.     // TODO: Add your control notification handler code here
  53.     UpdateData();
  54.     CFileDialog file( TRUE, "*.cll", m_filename, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, 
  55.                                     "CELL File(*.cll)|*.cll|", NULL );
  56.     if ( file.DoModal() == IDOK ){
  57.         m_filename = file.GetPathName( );
  58.     }
  59.     UpdateData(FALSE);
  60. }
  61.  
  62. void CDemoFileDlg::OnButtonOpen() 
  63. {
  64.     // TODO: Add your control notification handler code here
  65.     UpdateData();
  66.     if( m_filename.IsEmpty() ){
  67.         AfxMessageBox( "Please input filename!" );
  68.         GetDlgItem( IDC_EDIT_FILENAME )->SetFocus();
  69.     }
  70.     else{
  71.         if( m_ctrl.DoOpenFile( m_filename ) ){
  72.             m_ctrl.DoRedrawAll();
  73.             isopen = TRUE;
  74.         }
  75.     }
  76. }
  77.  
  78. void CDemoFileDlg::OnButtonSave() 
  79. {
  80.     // TODO: Add your control notification handler code here
  81.     UpdateData();
  82.     if( m_filename.IsEmpty() ){
  83.         AfxMessageBox( "Please input filename!" );
  84.         GetDlgItem( IDC_EDIT_FILENAME )->SetFocus();
  85.     }
  86.     else
  87.         m_ctrl.DoSaveFile( m_filename );
  88. }
  89.